<?php

/**
 * Author form.
 *
 * @package    embeddForm2
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class AuthorForm extends BaseAuthorForm {

    public function configure() {
        foreach ($this->object['Books'] as $index => $book) {
            $fieldName = 'book_' . $book['id'];

            $form = new BookForm($book);
            unset($form['author_id']);
            $this->embedForm($fieldName, $form);

            $label = '<input type="image" src="/images/delete.gif" name="submit" value="delete_' . $book['id'] . '">';
            if (count($this->object['Books']) - 1 == $index) {
                // this is the last book
                $label.= '<input type="image" src="/images/add.gif" name="submit" value="insert">';
            } else {
                $label.= '<img src="/images/empty.gif">';
            }
            $label.= ' Book ' . ($index + 1);

            $this->widgetSchema->setLabel($fieldName, $label);
        }
    }

}
